Copy object heading attribute to object text inside that heading

I have an attribute in a header. If the attribute changes, all the object (Text as headings) below that header should have the attribute modified as the heading attribute.
I will use a trigger to start the process, but how can i identify the objects below the heading?

Regards,
Silveira
Silveirax - Thu Jun 02 16:38:49 EDT 2011

Re: Copy object heading attribute to object text inside that heading
Mathias Mamsch - Thu Jun 02 17:33:28 EDT 2011

I think you don't need to ... When you change an attribute from a trigger, other triggers will not react on that changes (at least that was what I noticed on DOORS 8.2, I am not sure if it is a bug or a feature). You might want to try it.

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Copy object heading attribute to object text inside that heading
Silveirax - Fri Jun 03 11:35:36 EDT 2011

Mathias Mamsch - Thu Jun 02 17:33:28 EDT 2011
I think you don't need to ... When you change an attribute from a trigger, other triggers will not react on that changes (at least that was what I noticed on DOORS 8.2, I am not sure if it is a bug or a feature). You might want to try it.

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

I think i was not clear. If the attribute of an "object heading" is changed, i will stat a trigger. That trigger shall set the attribute for all the objects inside that header to this new value.
Example.
Was
Heading 1 level 1 => Attribute is OK
Object 1 inside level 1 => Attribute is Ok
Object 2 inside level 1 => Attribute is Ok
Heading 2 level 1 => Attribute is OK
Object 1 inside level 1 => Attribute is Ok
Object 2 inside level 1 => Attribute is Ok
Action
Heading level 1 => Attribute CHANGED to NOT_OK (trigger will be fired here)
Object 1 inside level 1 => Attribute is Ok
Object 2 inside level 1 => Attribute is Ok
Heading 2 level 1 => Attribute is OK (Nothing changes)
Object 1 inside level 1 => Attribute is Ok (Nothing changes)
Object 2 inside level 1 => Attribute is Ok (Nothing changes)

Will Be
Heading level 1 => Attribute is to NOT_OK
Object 1 inside level 1 => Attribute is NOT_OK (changed by the trigger)
Object 2 inside level 1 => Attribute is NOT_OK (changed by the trigger)
Heading 2 level 1 => Attribute is OK (Nothing changes)
Object 1 inside level 1 => Attribute is Ok (Nothing changes)
Object 2 inside level 1 => Attribute is Ok (Nothing changes)

Re: Copy object heading attribute to object text inside that heading
SystemAdmin - Fri Jun 03 11:38:55 EDT 2011

Look for the "for object in object" loop - it will go through the children of the heading object. To go through the all objects, you have to build up a recursive function.

Re: Copy object heading attribute to object text inside that heading
llandale - Fri Jun 03 13:22:44 EDT 2011

Silveirax - Fri Jun 03 11:35:36 EDT 2011
I think i was not clear. If the attribute of an "object heading" is changed, i will stat a trigger. That trigger shall set the attribute for all the objects inside that header to this new value.
Example.
Was
Heading 1 level 1 => Attribute is OK
Object 1 inside level 1 => Attribute is Ok
Object 2 inside level 1 => Attribute is Ok
Heading 2 level 1 => Attribute is OK
Object 1 inside level 1 => Attribute is Ok
Object 2 inside level 1 => Attribute is Ok
Action
Heading level 1 => Attribute CHANGED to NOT_OK (trigger will be fired here)
Object 1 inside level 1 => Attribute is Ok
Object 2 inside level 1 => Attribute is Ok
Heading 2 level 1 => Attribute is OK (Nothing changes)
Object 1 inside level 1 => Attribute is Ok (Nothing changes)
Object 2 inside level 1 => Attribute is Ok (Nothing changes)

Will Be
Heading level 1 => Attribute is to NOT_OK
Object 1 inside level 1 => Attribute is NOT_OK (changed by the trigger)
Object 2 inside level 1 => Attribute is NOT_OK (changed by the trigger)
Heading 2 level 1 => Attribute is OK (Nothing changes)
Object 1 inside level 1 => Attribute is Ok (Nothing changes)
Object 2 inside level 1 => Attribute is Ok (Nothing changes)

This may not be exactly what you want, but if you attribute had the property 'inherited' (sibling to 'default') then often when a Heading changed the value, so would all its children objects. However, if an object indeed has a specific value, such as changing "Obj 1 under Head 1" specifically to "OK", then changing the Heading will NOT change that subordinate, but will change "Obj 2 under Head 1".

If you use inheritance, it may be useful from time to time to generate a report on which objects indeed "hasSpecificValue(obj.NameAttr)" and those that do not.

Inheritance won't work if you routinely set Objects to "OK", but want to override all that with a Heading to "Not OK" value.

To answer your direct question: Object T (e.g. Obj 1 under Head 1) has ancestor H (e.g. Head 1) when the paragraph 'number' of H is the suffix of the paragraph 'number' of T. Something like this:

bool  IsSubordinate(Object oHead, oText)
{    // Is the Text object subordinate in the Hierarchy to the Heading object?
    if (null oHead or null oText)       return(false)
    if (oHead == oText)                 return(false)  // same object, you dim wit
    if (module(oHead) != module(oText)) return(false)  // in different Modules, nincompoop
 
    string ParaH = number(oHead)
    string ParaT = number(oText)
    int    lenH  = length(ParaH)
    int    lenT  = length(ParaT)
 
   return (lenH < lenT  and ParaT[0:LenH-1] == ParaH)
}  // end IsSubordinate()


Yes, it seems to me I recall that when a trigger sets an attribute value, that will not trigger the trigger again.

 

 

  • Louie